class Picture implements Comparable {
    Listing     listing
    SortedSet   images
    String      file
    Integer     operation
    String      caption
    String      description
    String      contentType
    Integer     width
    Integer     height
    Date        dateCreated = new Date()
    Date        lastUpdated = new Date()
    Boolean     confirmDelete

    static belongsTo = [ Listing ]
    static hasMany = [ images : Image ]

    static optionals = [ 'caption', 'description' ]

    static transients = [ 'file', 'operation', 'confirmDelete' ]

    static constraints = {
        caption(size: 0..40)
        description()
    }

    static mapping = {
        images cascade: 'all-delete-orphan', inverse: true
        description type: 'text'
        user index: 'pictures_user_index', unique: false
        album index: 'pictures_album_index', unique: false
    }

    static final Integer NoOp = 0
    static final Integer RotateClockWise90 = 1
    static final Integer RotateAntiClockWise90 = 2
    static final Integer Rotate180 = 3
    static final Integer Flip = 4
    static final Integer Flop = 5

    int compareTo(obj) {
        obj.id.compareTo(id)
    }
}